{include file="common/head"}
<head>
<title>系统设置</title>
<link    rel="stylesheet"    href="https://cdnjs.cloudflare.com/ajax/libs/jodit/3.24.2/jodit.es2018.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jodit/3.24.2/jodit.es2018.min.js"></script>    
</head>
<body style="">
    <div class=" p-3 my-3 " style="max-width: 800px;"  >
    <h2>系统设置</h2>
    <!--  <a href="/index/xcxz"><button class="btn btn-primary"> 学车须知</button></a> 
      <a href="/index/agreement"><button class="btn btn-secondary">用户协议</button></a>
    </h2> -->
    <form name='form1' method="post" action="/index.php/admin/sys" enctype="multipart/form-data">
      <input type="hidden" name="id" value="{$sys.id}"/>
      <div class="mb-3 mt-3">
        <lable for="company_name" class="form-label">公司名称:</label>
        <input type="text" class="form-control" id="company_name" name="company_name" value="{$sys.company_name}" placeholder="company_name" />
      </div>
      <div class="mb-3 mt-3">
        <lable for="sys_name" class="form-label">系统名称:</label>
        <input type="text" class="form-control" id="sys_name" name="sys_name" value="{$sys.sys_name}" placeholder="system name" />
      </div>

      <div class="mb-3 mt-3">
        <lable for="copy_right" class="form-label">版权信息(CopyRight):</label>
        <input type="text" class="form-control" id="copy_right" name="copy_right" value="{$sys.copy_right}" placeholder="copy_right information" />
      </div>
      <div class="mb-3 mt-3">
        <lable for="address" class="form-label">Address:</label>
        <input type="text" class="form-control" id="address" name="address" value="{$sys.address}" placeholder="address " />
      </div>
      <div class="mb-3 mt-3">
        <lable for="tel" class="form-label">公司电话(Tel):</label>
        <input type="text" class="form-control" id="tel" name="tel" value="{$sys.tel}" placeholder="tel " />
      </div>
      <div class="mb-3 mt-3">
        <lable for="email" class="form-label">Eamil:</label>
        <input type="text" class="form-control" id="email" name="email" value="{$sys.email}" placeholder="email " />
      </div>

      <div class="mb-3">
        <label for="currency_symbol" class="form-label">货币符号（$/￥）:</label>
        <input class="form-control" id="currency_symbol" name="currency_symbol" value="{$sys.currency_symbol}" />
      </div>
      <div class="mb-3">
        <label for="msg" class="form-label">首页公告:</label>
        <textarea class="form-control" id="msg" name="msg" rows="3">{$sys.msg}</textarea>
      </div>

      <div class="mb-3">
        <label for="about_msg" class="form-label">关于我们:</label>
        <textarea id="about_msg" name="about_msg">{$sys.about_msg}</textarea>
      </div>  

      <button  type="button" class="btn btn-primary" onclick="doSave()">保存(Save)</button>

    </form>
    
    </div>

<script type="text/javascript">
    var editor = Jodit.make('#about_msg',{
      toolbarButtonSize: 'small',
    });
    // var editor = Jodit.make('#msg',{
    //   toolbarButtonSize: 'small',
    // });
    //editor.value = ''; 

    function doSave(){
      if(!$("#sys_name").val()) {
        layer.msg("无效的名称(Invalid name)!");
        return 0;
      }
      
      //询问框
      layer.confirm('是否确定保存设置?', {
        btn: ['YES','CANCEL'] //按钮
      }, function(){
        $('form[name="form1"]').submit();
      }, function(){
        layer.msg("Cancel!");
        return 0;
      });
    }



  $(document).ready(function(){

    $(".goods_image").on('click',function(){
        var img = $(this).attr('src');
        if(!img.trim()) return;

        layer.open({
          type: 1,
          title:'',
          closeBtn: 0, //不显示关闭按钮
         // anim: 1,
          time: 5*1000,
          shadeClose: true, //开启遮罩关闭              
          skin: 'layui-layer-rim', 
          content: "<img src='"+img+"' style='width:100%'>"
        });
    })


    $(".img_remove").on('click',function(){
      var src=$(this).attr('src');
      var row_id=$(this).attr('row_id');

      //询问框
      layer.confirm('是否确定删除图片?', {
        btn: ['确定','取消'] //按钮
      }, function(){
        
        $.post('/index.php/sys/img_remove',{tb:'sys',row_id:1,field:'top_images',src:src},function(res){
            if(res.code){
                layer.msg(res.msg);
                location.reload();
            }
            
        })

      }, function(){
        layer.msg("好的!");
        return 0;
      });
    })

    $('#img_add').on('click',function(){$('#file1').click()})
    //提交图片
    $("#file1").on('change',function(e){
      var el1='<input name="tb"  type="hidden" value="sys+top_images" />';
      var el2='<input name="source_url" type="hidden" value="/admin/sys" />';
      $('#file1').after(el1).after(el2);

      $('form[name="form1"]').attr('action','/sys/img_add').submit();
    })

  })  
</script>


</body>
</html>
